package cn.zhaozhiqi.constants;


import java.util.Arrays;
import java.util.List;

//常量维护
public class Constants {

    //手机号正则表达式
    public static final String CHINA_PHONE_REGEX =  "^((13[0-9])|(14[0,1,4-9])|(15[0-3,5-9])|(16[2,5,6,7])|(17[0-8])|(18[0-9])|(19[0-3,5-9]))\\d{8}$";
    public static final String CHACT_IDNUM_REGEX =  "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";

    //编码
    public static final String UTF_8 = "UTF-8";


    //统一支付单的支付状态
    public class PayStatus{
        //0：待支付 1.支付成功 2：支付超时
        public static final int WATTING = 0;
        public static final int PAY_SUCCESS = 1;
        public static final int PAY_TIMEOUT = 2;


    }

    //支付方法


    public class PayType{
        //支付方式:0余额直接，1微信，2支付宝,3银联")
        public static final int BALANCE = 0;
        public static final int WECHAT = 1;
        public static final int ALIPAY = 2;

    }
    public class TravelMethod{
        /*
        	计算方式，取值：
            driving：驾车
            walking：步行
            bicycling：自行车
         */
        public static final String DRIVING = "driving";


    }
    public class Profitsharing{
        /*
        	计算方式，取值：
            driving：驾车
            walking：步行
            bicycling：自行车
         */
        public static final int NO_SHARING = 0;
        public static final int SHARING = 1;


    }


    //司机服务
    public class Driver {
        public static final String OPENID_URL = "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code";
        public static final String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";
        public static final String GET_PHONE_URL = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%s";
        public static final int TYPE_ADMIN = 0;
        public static final int TYPE_DRIVER = 1;//0是平台账户，1是司机账户，2是客户账户
        public static final int TYPE_CUSTOMER = 2;
    }
    //远程调用
    public class Remote {
        //服务名
        public static final String SERVICE_UAA = "fccar-service-uaa";
        public static final String SERVICE_RULE = "fccar-service-rule";
        public static final String SERVICE_BIGDATA = "fccar-service-bigdata";
        public static final String SERVICE_DRIVER = "fccar-service-driver";

        public static final String PREFIX_LOGIN_REMOTE = "/login/remote";
        public static final String PREFIX_FEIGNCLIENT = "cn.zhaozhiqi.remote";
    }

    public class Redis {
        //服务名
        public static final String PERMISSION = "permission:";
        //司机设置
        public static final String DRIVER_SETTING = "driver-setting:";
        //司机GEO存储的大key
        public static final String DRIVER_GEO_KEY = "drivergeo";
        //登录人的返回前端的基础信息，缓存到redis
        public static final String LOGINVO = "loginVo:";
        //订单创建完成后放入redis中，等待司机抢单
        public static final String CREATE_ORDER = "create-order:";
        //多个司机抢单的时候，将要抢的唯一订单加上redisson锁
        public static final String Kill_ORDER = "kill-order:";
        //缓存司机的实时位置，用于司乘同显
        public static final String DRIVER_CURRENT_LOCATION = "driver-location:";

    }
    //司机认证状态
    public class AuthStatus {
        //服务名
        public static final Integer WATTING = 0;
        public static final Integer PASS = 1;
        public static final Integer REJECT = 2;

    }
    //RocketMQ的常量类
    public class Mq {
        //服务名
        public static final String ORDER_TOPIC = "order-create-mq";
        //order服务发送消息到pay微服务的topic,用来生成统一支付单
        public static final String CREATE_PAY_TOPIC = "create-pay";
        public static final String ORDER_LAG_NAME = "lag%s";
        //order服务发送消息到pay微服务的topic,用来生成统一支付单
        public static final String CREATE_PAY_LAG = "lag-order-pay";
        //order服务发送消息到pay微服务的txProducerGroup,用来生成统一支付单
        public static final String TX_ORDER_PAY_GROUP = "tx-order-pay-group";

        //支付完成后广播给司机服务和订单服务的操作
        public static final String PAY_SUCCESS_GROUP = "pay-success-group";
        public static final String TOPIC_PAY_SUCCESS = "topic-pay-success";
        public static final String TAG_PAY_SUCCESS = "tag-pay-success";

    }
    //订单状态
    public class OrderStatus {
        public static final Integer ORDER_STATUS_WAIT = 0;//等待接单
        public static final Integer ORDER_STATUS_ACCEPTED = 1;//已接单
        public static final Integer ORDER_STATUS_ARRIVE = 2;//司机已到达
        public static final Integer ORDER_STATUS_START_DRIVING = 3;//开始代驾
        public static final Integer ORDER_STATUS_COMPLETE_DRIVED = 4;//结束代驾
        public static final Integer ORDER_STATUS_ENSURE = 5;//司机确认费用
        public static final Integer ORDER_STATUS_NOT_PAY = 6;//未付款
        public static final Integer ORDER_STATUS_PAYED = 7;//已付款
        public static final Integer ORDER_STATUS_FINISH_ORDER = 8;//订单已结束
        public static final Integer ORDER_STATUS_CUSTOMER_CANCEL_ORDER = 9;//顾客撤单
        public static final Integer ORDER_STATUS_DRIVER_CANCEL_ORDER = 10;//司机撤单
        public static final Integer ORDER_STATUS_ACCIDENT_CLOSE = 11;//事故关闭
        public static final Integer ORDER_STATUS_OTHER = 12;//其他
        public static final Integer ORDER_STATUS_TIMEOUT = 13;//订单超时
        //不可接单的状态
        public static final List<Integer> ORDER_STAY = Arrays.asList(
                ORDER_STATUS_WAIT,
                ORDER_STATUS_ACCEPTED,
                ORDER_STATUS_ARRIVE,
                ORDER_STATUS_START_DRIVING,
                ORDER_STATUS_COMPLETE_DRIVED,
                ORDER_STATUS_ENSURE,
                ORDER_STATUS_NOT_PAY
        );
        //订单正在进行的状态
        public static final List<Integer> ORDER_RUNNING = Arrays.asList(
                ORDER_STATUS_ACCEPTED,
                ORDER_STATUS_ARRIVE,
                ORDER_STATUS_START_DRIVING,
                ORDER_STATUS_COMPLETE_DRIVED,
                ORDER_STATUS_ENSURE
        );

    }
}
